package com.tarzan.edu.controller.api;

import com.tarzan.common.core.base.BaseResponse;
import com.tarzan.common.core.exception.BusinessException;
import com.tarzan.edu.entity.api.EduTeacherApiResp;
import com.tarzan.edu.service.IEduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Package com.tarzan.edu.controller.api
 * @Title EduTeacherApiController
 * @Description TODO 教师API接口
 * @Author liujinshan
 * @CreateTime 2021/10/26 11:19
 */
@RestController
@RequestMapping("edu/api")
public class EduTeacherApiController {

    @Autowired
    private IEduTeacherService iEduTeacherService;

    /**
     * @title findTeacherFrontById
     * @description TODO
     * @param id
     * @return com.tarzan.common.core.base.BaseResponse<com.tarzan.edu.entity.api.EduTeacherApiResp> 
     * @author liujinshan
     * @data 2021/10/27 14:11
     */
    @GetMapping(value = "findTeacherFrontById/{id}")
    public BaseResponse<EduTeacherApiResp> findTeacherFrontById(@PathVariable String id){
        BaseResponse<EduTeacherApiResp> response;
        try{
            response = BaseResponse.ok(iEduTeacherService.findTeacherFrontById(id));
        } catch (BusinessException e){
            return BaseResponse.error(e.getCode(),e.getMsg());
        } catch (Exception e){
            return BaseResponse.error("500",e.getMessage());
        }
        return response;
    }

}
